// const Comments = require('./../db/comment');
const Pusher = require("./push");


module.exports = {
  addCommentBySkey: (req, res, next) => {
    const { skey, content, bookid } = req.boby;
    Comments.addCommentBySkey(skey, content, bookid).then(res => {
      if (res && res.insertId) {
        // 推送评论消息

        Pusher.pushMessageToUser(req);
        res.json({
          result: 0,
          errMsg: "insert success"
        })
      } else {
        res.json({
          result: -2,
          errMsg: "提交失败"
        })
      }
    }).catch(err => {
      res.json({
        result: -3,
        errMsg: "网络错误"
      })
    })
  }
}